/**
 * ======================================
 * 访客管理
 * author: SKY-D
 * file: index.vue
 * date: 2022/6/12 14:50
 * ======================================
 */
<template>
  <page>
    <!--    功能-->
    <!--    查询条件-->
    <el-row slot="where">
      <el-col :span="24" class="k-text-left k-lh-2-2">
        <!-- <el-button class="k-mr-10" type="primary" @click="handleCreate">新增</el-button> -->
      </el-col>
      <el-col :span="24" class="k-text-left k-lh-2-2">
        <span>现住址</span>
        <address2-select v-model="WHERE.address" class="k-mr-10" />

        <span>姓名/身份证/手机号 ：</span>
        <el-input v-model="WHERE.search" class="k-width-150-p k-mr-10" />
        <el-button type="primary" @click="_search">查询</el-button>
        <el-button type="primary" @click="_reset">重置</el-button>
      </el-col>
    </el-row>
    <!--    表格-->
    <el-table
      slot="table"
      ref="tb"
      v-loading="LOADING"
      :data="CLASS_TABLE_DATA"
      :size="SIZE"
      border
      :height="LIST_HEIGHT"
      style="width: 100%"
      @selection-change="_handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="55"
      />
      <template v-for="(item) in setting">
        <el-table-column
          v-if="item.key === 'action'"
          :key="item.id"
          :label="item.name"
          :prop="item.key"
          :width="item.value"
        >
          <template slot-scope="scope">
            <el-button v-permission="['FLOW_PERSON:VIEW']" @click="handleDetail(scope.row)">详情</el-button>
            <el-button v-permission="['FLOW_PERSON:DEL']" @click="handleDel(scope.row)">删除</el-button>
          </template>

        </el-table-column>
        <el-table-column
          v-else
          :key="item.id"
          :label="item.name"
          :prop="item.key"
          :width="item.value"
        />
      </template>
    </el-table>
    <!--    分页-->
    <pagination slot="pagination" />
    <!--    弹窗-->
    <template slot="modal">
      <form-modal :visible.sync="FORM_VISIBLE" :type="FORM_TYPE" :data="FORM_DATA" @refresh="_getList" />
      <user-info-modal :data="detailId" :visible.sync="detailVisible" />
    </template>
  </page>
</template>

<script>
import list from '@/list'
import Address2Select from '@/components/Select/address2Select'
import FloatingClass from '@/models/floating-class'
import { del, getList } from '@/api/floating'
import formModal from './components/form'
import userInfoModal from '@/views/company/list/components/person/scan'
import { streetOptions } from '@/list/data'
const floatingClass = new FloatingClass()
export default {
  name: 'DeepInterpretationOrder',
  components: { formModal, userInfoModal, Address2Select },
  mixins: [list],
  data() {
    return {
      streetOptions,
      setting: floatingClass.list(),
      WHERE: {
        address: {
          province: '',
          city: ''
        },
        search: '',
        start_age: '',
        end_age: '',
        start_time: '',
        end_time: ''
      },
      detailVisible: false,
      detailId: 0
    }
  },
  created() {
    this.LIST_API = getList
  },
  mounted() {
  },
  methods: {
    _setClass() {
      console.log('[mixin][list]设置类')
      const list = []
      this.TABLE_DATA.forEach(v => {
        const item = new FloatingClass(v)
        list.push(item)
      })
      this.CLASS_TABLE_DATA = list
    },
    handleCreate() {
      console.log('添加')
      this.FORM_TYPE = 'create'
      this.FORM_VISIBLE = true
    },
    handleImport() {
      console.log('导入')
      this.$notify.success('导入')
    },
    handleDetail(item) {
      console.log('详情', item)
      this.detailId = item.id
      this.detailVisible = true
    },
    handleDel(item) {
      console.log('删除', item)
      this.$confirm('确认删除？')
        .then(_ => {
          del(item.id).then(res => {
            console.log('删除结果', res)
            this._showSuccess('删除成功')
          })
        })
        .catch(_ => {})
    }
  }
}
</script>
